package pub.developers.forum.facade.validator;

import pub.developers.forum.api.request.AdminBooleanRequest;
import pub.developers.forum.api.request.article.ArticleAddTypeRequest;
import pub.developers.forum.api.request.article.ArticleDeleteRequest;
import pub.developers.forum.api.request.article.ArticleInformRequest;
import pub.developers.forum.api.request.article.ArticleSaveArticleRequest;
import pub.developers.forum.common.support.CheckUtil;



public class ArticleValidator {

    public static void validatorBooleanRequest(AdminBooleanRequest booleanRequest) {
        CheckUtil.checkParamToast(booleanRequest, "request");
        CheckUtil.checkParamToast(booleanRequest.getId(), "id");
        CheckUtil.checkParamToast(booleanRequest.getIs(), "is");
    }

    public static void addType(ArticleAddTypeRequest request) {

    }

    public static void saveArticle(ArticleSaveArticleRequest request) {
        CheckUtil.checkParamToast(request, "request");
//        CheckUtil.checkParamToast(request.getTypeId(), "typeId");
//        CheckUtil.checkParamToast(request.getTitle(), "title");
//        CheckUtil.checkParamToast(request.getContentType(), "contentType");
        CheckUtil.checkParamToast(request.getMarkdownContent(), "markdownContent");
        CheckUtil.checkParamToast(request.getHtmlContent(), "htmlContent");
        CheckUtil.checkParamToast(request.getTagIds(), "tagIds");
    }


    //删除文章
    public static void deleteArticle(ArticleDeleteRequest request) {
        CheckUtil.checkParamToast(request , "request"); //检查request是否为空
        CheckUtil.checkParamToast(request.getIds() , "ids"); //检查request中的字符是否为空
    }

    //用户举报文章的参数校验
    public static void informArticle(ArticleInformRequest request) {
        CheckUtil.checkParamToast(request , "type"); //帖子类型
        CheckUtil.checkParamToast(request , "informed"); //被举报的帖子的id
    }
}
